package com.zc.angelica.controller;

import com.zc.angelica.entity.ResponseData;
import com.zc.angelica.entity.request.Register;
import com.zc.angelica.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;


    @PostMapping("/register")
    public ResponseData register(@RequestBody Register register, HttpServletRequest request){
        return accountService.register(register,request);
    }

    @GetMapping("/disable")
    public ResponseData disable(Long id){
        return accountService.disable(id);
    }

    @GetMapping("/locking")
    public ResponseData locking(Long id){
        return accountService.locking(id,2);
    }

    @GetMapping("/unlock")
    public ResponseData unlock(Long id){
        return accountService.unlock(id);
    }

    @GetMapping("/setExpirationTime")
    public ResponseData setExpirationTime(Long id, Date endTime){
        return accountService.setExpirationTime(id,endTime);
    }

    @GetMapping("/getAccountInfo")
//    @PreAuthorize("hasPermission('addMenu','add')")
    public ResponseData getAccountInfo(){
        return accountService.getAccountInfo();
    }
}
